/** The player's mobile, which has special serialization rules.
*/
function PlayerMobile()
{
	this.skills =
	{
		unarmed: 1,
		melee: 1,
		firearms: 1
	};
	this.skillGains =
	{
		unarmed: 0,
		melee: 0,
		firearms: 0
	};
	this.worldMapVisRange = 3;
	this.equipment = {};
	this.init();
}
PlayerMobile.prototype = new Mobile(
	"Eddy Vance",				// Name
	"@",						// Character
	Color.white,				// Foreground color
	null,						// Background color
	100,						// HP
	10,							// Speed
	{							// Controller description
		sense: "none",
		alert: "none",
		idle: "none",
		wimpy: "none",
		flee: "none",
		attack: "none",
		follow: "none"
	}
);
PlayerMobile.prototype.serialize = function(s)
{
	Mobile.prototype.serialize.call(this, s);
	s.push(this.name, this.skills, this.skillGains);
}
PlayerMobile.prototype.deserialize = function(s)
{
	this.skillGains = s.pop();
	this.skills = s.pop();
	this.name = s.pop();
	Mobile.prototype.deserialize.call(this, s);
}
/** Checks the palyer's skill against a set difficulty and handles skill gains.
 *@param skillName The name of the skill to check.
 *@param difficulty The difficulty level to check against.
 */
PlayerMobile.prototype.skillCheck = function(skillName, difficulty)
{
	var skill = this.skills[skillName];
	if(!skill)
		return false;
	var success = Math.random() * 10 < ((skill - difficulty) + 5);
	if(Math.random() * 10 > ((skill - difficulty) + 5))
	{
		++this.skillGains[skillName];
		if(this.skillGains[skillName] >= 20)
		{
			this.skillGains[skillName] = 0;
			++this.skills[skillName];
			logWindow.pushMessage("%b0You gained a level in " + skillName + " skill! [" + this.skills[skillName] + "]");
		}
	}
	return success;
}
Entity.registerCtor(PlayerMobile, 1);
